package Reflect;

import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
//        Class cla=String.class;
//        Class cla= ArrayList.class;
//        Class cla=Class.forName("java.lang.String");
//        Class cla=Class.forName("java.util.ArrayList");
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入类名");
        Class cla=Class.forName(sc.nextLine());


        String name=cla.getName();
        System.out.println(name);

        name=cla.getSimpleName();
        System.out.println(name);

        Package pac=cla.getPackage();
        System.out.println(pac.getName());


        Method[] methods=cla.getMethods();
        System.out.println("共"+methods.length+"个方法");
        for (Method method:methods){
            System.out.println(method.getName());
        }
    }
}
